﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data.SqlClient;
using DevExpress.Utils;
using DevExpress.XtraSplashScreen;
using ISumen;
using Sumen.Business;
using Sumen.Business.Model.Presenter.Sys;
using Sumen_Stock.LookAndFeel.Sumen_System;
using ClassLib.UserControl.DanhMuc;

namespace Sumen_Stock.LookAndFeel.Category
{
    public partial class Frm_Product_Color : DevExpress.XtraEditors.XtraForm
    {
        private FromCode _fromCode = FromCode.FrmProductColor;
        public Frm_Product_Color()
        {
            InitializeComponent();
            ucDanhMuc1.mySetValidate = new UCDanhMuc.setValidate(myValidate);
            //if (ClsPublic.Writelog == "1")
            //{
            //    SysLogPresenter log = new SysLogPresenter();
            //    log.Add(_fromCode, EnumFormStatus.View, "", "");
            //}
        }

        private void myValidate(DevExpress.XtraGrid.Views.Grid.GridView g, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            try
            {
                e.Valid = ucDanhMuc1.Check_NULL(g, "Color_Name", "Không được rỗng");
                if (!e.Valid) return;
                e.Valid = ucDanhMuc1.Check_MA(g, "", "Color_Code");
                if (!e.Valid) return;
                e.Valid = ucDanhMuc1.Check_Length(g, "Color_Code", 2, 2);
                if (!e.Valid) return;
            }
            catch
            {

            }
        }
        public override void Refresh()
        {
            SplashScreenManager.ShowForm(typeof(WaitForm1));
            base.Refresh();
            ucDanhMuc1.reLoad();
            ucDanhMuc1.reLoadParent();
            SplashScreenManager.CloseForm();
        }
        private void Frm_Product_Color_Load(object sender, EventArgs e)
        {
          
        }

        private void Frm_Product_Color_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (ClsPublic.Writelog == "1" && ucDanhMuc1.IsSave)
            {
                SysLogPresenter log = new SysLogPresenter();
                log.Add(_fromCode, EnumFormStatus.Modify, "", "");
            }
        }




    }
}